package com.itheima.service.impl;

import com.itheima.dao.AccountDao;
import com.itheima.service.AccountService;
import com.itheima.service.LogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.io.IOException;


@Service
public class AccountServiceImpl implements AccountService {

    @Autowired
    private AccountDao accountDao;
    //1.注入日志业务对象
    @Autowired
    private LogService logService;
    //    超时事务

//    @Override
//    @Transactional(timeout = 2)
//    //    @Transactional
//    public void transfer(String out,String in ,Double money) throws IOException {
//        accountDao.outMoney(out, money);
//        try {
//            Thread.sleep(3000);
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        }

//        accountDao.inMoney(in, money);
    @Transactional
    @Override
    public void transfer(String out, String in , Double money) {
            accountDao.outMoney(out,money);
            int i = 1/0;
            accountDao.inMoney(in,money);
    }

}

